package com.ruoyi.period.service.impl;

import java.util.List;

import com.ruoyi.period.domain.Client;
import com.ruoyi.period.domain.Employees;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.period.mapper.MyclassMapper;
import com.ruoyi.period.domain.Myclass;
import com.ruoyi.period.service.IMyclassService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 课期Service业务层处理
 *
 * @author ruoyi
 * @date 2021-11-05
 */
@Service
public class MyclassServiceImpl implements IMyclassService {
    @Autowired
    private MyclassMapper myclassMapper;

    /**
     * 查询课期
     *
     * @param id 课期主键
     * @return 课期
     */
    @Override
    public Myclass selectMyclassById(Long id) {
        return myclassMapper.selectMyclassById(id);
    }

    /**
     * 查询课期列表
     *
     * @param myclass 课期
     * @return 课期
     */
    @Override
    public List<Myclass> selectMyclassList(Myclass myclass) {
        return myclassMapper.selectMyclassList(myclass);
    }

    /**
     * 新增课期
     *
     * @param myclass 课期
     * @return 结果
     */
    @Override

    @Transactional(rollbackFor = Exception.class)
    public int insertMyclass(Myclass myclass, List<Integer> clientIdList){
        int index = 0;
        index = myclassMapper.insertMyclass(myclass);
        myclassMapper.insertClientClass(clientIdList, myclass.getId());
        return index;
    }

    /**
     * 修改课期
     *
     * @param myclass 课期
     * @return 结果
     */
    @Override
    public int updateMyclass(Myclass myclass) {
        return myclassMapper.updateMyclass(myclass);
    }

    /**
     * 批量删除课期
     *
     * @param ids 需要删除的课期主键
     * @return 结果
     */
    @Override
    public int deleteMyclassByIds(Long[] ids) {
        return myclassMapper.deleteMyclassByIds(ids);
    }

    /**
     * 删除课期信息
     *
     * @param id 课期主键
     * @return 结果
     */
    @Override
    public int deleteMyclassById(Long id) {
        return myclassMapper.deleteMyclassById(id);
    }

    /**
     * @param courseId 传入课程id
     * @return 结果
     */
    @Override
    public List<Client> selectClientByCourseId(Long courseId) {
        return myclassMapper.selectClientByCourseId(courseId);
    }

    /**
     * @return 结果
     */
    @Override
    public List<Employees> selectEmployees() {
        return myclassMapper.selectEmployees();
    }



    @Override
    public int insertClassClient(List<Integer> clientList, Long classId) {
        return myclassMapper.insertClientClass(clientList, classId);
    }
}
